using System.Linq;
using UnityEngine;
using WolfCarol.AvgToolkit.Save;

namespace WolfCarol.AvgToolkit.Examples
{
    public class ImagePresenter : MonoBehaviour, ISavable<ImageData[]>
    {
        [SerializeField] private StageImage[] m_images;

        public void Clear()
        {
            foreach (var image in m_images)
            {
                image.Clear();
            }
        }

        public ImageData[] Save()
        {
            return m_images.Select(image => image.Save()).ToArray();
        }

        public void Load(ImageData[] obj)
        {
            for (int i = 0; i < m_images.Length; i++)
            {
                m_images[i].Load(obj[i]);
            }
        }
    }
}